VERSION 5.00
Begin VB.Form frmPais 
   BackColor       =   &H80000013&
   Caption         =   "ABM Paises"
   ClientHeight    =   3090
   ClientLeft      =   3060
   ClientTop       =   3450
   ClientWidth     =   4680
   Icon            =   "frmPais.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   Begin VB.CommandButton cmdsalir 
      Caption         =   "&Salir (Esc)"
      Height          =   375
      Left            =   3360
      TabIndex        =   7
      Top             =   2400
      Width           =   1095
   End
   Begin VB.CommandButton cmdcancelar 
      Caption         =   "&Cancelar"
      Height          =   375
      Left            =   1800
      TabIndex        =   6
      Top             =   2400
      Width           =   1095
   End
   Begin VB.CommandButton cmdAceptar 
      Caption         =   "&Aceptar"
      Height          =   375
      Left            =   480
      TabIndex        =   5
      Top             =   2400
      Width           =   1095
   End
   Begin VB.TextBox txtnombre 
      Height          =   285
      Left            =   1200
      TabIndex        =   4
      Top             =   1800
      Width           =   2055
   End
   Begin VB.CommandButton cmdmodificar 
      Caption         =   "&Modificar"
      Height          =   375
      Left            =   3480
      TabIndex        =   2
      Top             =   600
      Width           =   975
   End
   Begin VB.CommandButton cmdnuevo 
      Caption         =   "&Nuevo"
      Height          =   375
      Left            =   3480
      TabIndex        =   1
      Top             =   120
      Width           =   975
   End
   Begin VB.ListBox lstpais 
      Height          =   1425
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3135
   End
   Begin VB.Label lblnombre 
      BackColor       =   &H80000013&
      Caption         =   "Nombre:"
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   1800
      Width           =   735
   End
End
Attribute VB_Name = "frmPais"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim BAN As Integer
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then Unload Me
End Sub
Private Sub cmdAceptar_Click()
    Select Case BAN
    Case 1
        Conectar
        ConsultaSql "select * from pais"
        rs.AddNew
        rs!nombre = txtnombre.text
        rs.Update
        desconectar
    Case 2
        Conectar
        ConsultaSql "select * from pais where id_pais = ' " & lstpais.ItemData(lstpais.ListIndex) & " '"
        rs!nombre = txtnombre.text
        rs.Update
        desconectar
    End Select
    cargarlista
    cmdAceptar.Enabled = False
    cmdCancelar.Enabled = False
    cmdSalir.Enabled = True
    cmdNuevo.Enabled = True
    txtnombre.Enabled = False
    lblNombre.Enabled = False
    lstpais.Enabled = True
    txtnombre.text = ""
End Sub

Private Sub cmdcancelar_Click()
lstpais.Enabled = True
cmdNuevo.Enabled = True
cmdSalir.Enabled = True
cmdCancelar.Enabled = False
cmdAceptar.Enabled = False
lblNombre.Enabled = False
txtnombre.Enabled = False

End Sub



Private Sub cmdmodificar_Click()
BAN = 2
lstpais.Enabled = False
lblNombre.Enabled = True
txtnombre.Enabled = True
cmdAceptar.Enabled = True
cmdCancelar.Enabled = True
cmdModificar.Enabled = False

cmdNuevo.Enabled = False
cmdSalir.Enabled = False
End Sub

Private Sub cmdnuevo_Click()
BAN = 1
'lstpais.ListIndex = -1
lblNombre.Enabled = True
txtnombre.Enabled = True
lstpais.Enabled = False
cmdAceptar.Enabled = True
cmdCancelar.Enabled = True
cmdSalir.Enabled = False
cmdModificar.Enabled = False
cmdNuevo.Enabled = False

txtnombre.text = ""

End Sub

Private Sub cmdSalir_Click()
desconectar

Unload Me
End Sub

Private Sub Form_Load()
lblNombre.Enabled = False
txtnombre.Enabled = False
cmdAceptar.Enabled = False
cmdCancelar.Enabled = False

cmdModificar.Enabled = False
cargarlista


End Sub

Private Sub lstpais_Click()
txtnombre.text = lstpais.List(lstpais.ListIndex)
cmdModificar.Enabled = True

End Sub

Private Sub cargarlista()
lstpais.Clear
Conectar
ConsultaSql "select * from pais order by nombre"
If rs.RecordCount <> 0 Then
    rs.MoveFirst
    i = 0
    Do While Not rs.EOF
       lstpais.AddItem (rs!nombre)
       lstpais.ItemData(i) = rs!id_pais
       i = i + 1
       rs.MoveNext
    Loop
End If
End Sub

